<p> <code> PreparedStatement </code> 和 <code> ResultSet </code>中的参数从1开始编号，任何小于1的参数值都是错误的。</p>

<h2>不规范的代码示例</h2>

<pre>
PreparedStatement ps = con.prepareStatement("SELECT fname, lname FROM employees where hireDate > ? and salary < ?");
ps.setDate(0, date);  // 不合规
ps.setDouble(3, salary);  // 不合规

ResultSet rs = ps.executeQuery();
while (rs.next()) {
  String fname = rs.getString(0);  // 不合规
  // ...
}
</pre>

<h2>正确的代码示例</h2>

<pre>
PreparedStatement ps = con.prepareStatement("SELECT fname, lname FROM employees where hireDate > ? and salary < ?");
ps.setDate(1, date);
ps.setDouble(2, salary);

ResultSet rs = ps.executeQuery();
while (rs.next()) {
  String fname = rs.getString(1);
  // ...
}
</pre>